<?php

class UpdateAction extends Action
{
    /**
     * 首页
     */
    public function room(){
        $postStr = file_get_contents("php://input");
        $array = (array)simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
        $openid = $array['openid'];
        // $total_fee = $array['total_fee'];
        $attach = explode(',', $array['attach']);
        $map['wx_orderid'] = $array['transaction_id'];
        $map['pay_time'] = time();
        if ($array['result_code'] == 'SUCCESS' && $array['return_code'] == 'SUCCESS') {
            
            //保存订单数据
            $userid = M('wxuser')->where(array('openid'=>$openid))->getField('id');
            $map['order_status'] = 1;
            $ss['userid'] = $userid;
            $ss['wx_orderid'] = '';
            file_put_contents('test.text',$map);
            M('order_room_result')->where($ss)->save($map);
             
        }
        

        // $openid = 'odhYGj5FDCiFcxMPOu11je4k4XC4';
        // $map['wx_orderid'] = 666666666666666;
        // $map['pay_time'] = time();
        // $userid = M('wxuser')->where(array('openid'=>$openid))->getField('id');dump($userid);
        // $map['order_status'] = 1;
        // $ss['userid'] = $userid;
        // $ss['wx_orderid'] = '';
        // file_put_contents('test.text',$map);
        // $save = M('order_room_result')->where($ss)->save($map);
        // if($save){
        //     echo 'succ';
        // }else{
        //     echo 'error';
        // }
    }


    
   

}